package com.zh.web.openApi;

import com.zh.common.exception.BusinessException;
import com.zh.web.base.ApiResult;
import com.zh.web.config.DefaultFeignConfig;
import com.zh.web.domain.media.vo.ArticleVo;
import com.zh.web.domain.media.vo.VideoVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;
import java.util.List;

@FeignClient(name = "ls-service-media", path = "/video", configuration = DefaultFeignConfig.class, contextId = "videoClient", fallback = VideoClientFallback.class)
public interface VideoClient {


    @PostMapping("/list")
    ApiResult<List<VideoVo>> listArticle(@RequestBody List<Long> ids);

    @GetMapping("/list/after")
    ApiResult<List<VideoVo>> listArticleAfterTime(@RequestParam("time") LocalDateTime time);
}

class VideoClientFallback implements VideoClient {

    @Override
    public ApiResult<List<VideoVo>> listArticle(List<Long> ids) {
        throw new BusinessException("系统繁忙,请稍后再试");
    }

    @Override
    public ApiResult<List<VideoVo>> listArticleAfterTime(LocalDateTime time) {
        throw new BusinessException("系统繁忙,请稍后再试");
    }
}
